### Project 6 L298N Motor Driver ![](media/wps24.jpg) **1.Introduction** Using L298N made by ST Company as the control chip, the module has characteristics of strong driving ability, low calorific value and strong anti-interference ability. This module can use built-in 78M05 for electric work via a driving power supply part. But to avoid the damage of the voltage stabilizing chip, please use an external 5V logic supply when using more than 12V driving voltage. Using large capacity filter capacitor, this module can follow current to protect diodes and improve reliability. **2.Specification** - Working Mode: H bridge (double lines) - Control Chip: L298N (ST) - Logical Voltage: 5V - Driving Voltage: 5V-35V - Logical Current: 0mA-36mA - Driving Current: 2A (MAX single bridge) - Storage Temperature: (-20 °C)-(+135 °C) - Maximum Power: 25W - Weight: 30g - Periphery Dimension: 43 x 43 x 27 mm(L x W x H) **3.Circuit Connection** ![](media/wps25.png) **4.Circuit Connection** ![](media/wps26.png) **5.Sample Code** ```c int IN1=5; int IN2=6; int IN3=7; int IN4=8; int ENA=9; int ENB=10; void setup() { for (int i = 5; i <11; i ++) { pinMode(i, OUTPUT); } } void loop() { // rotate CW digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); analogWrite(ENA,200); digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); analogWrite(ENB,200); delay(1000); // pause for 1S analogWrite(ENA,0); analogWrite(ENB,0); delay(1000); // rotate CCW digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); analogWrite(ENA,100); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); analogWrite(ENB,100); delay(1000); // pause for 1S analogWrite(ENA,0); analogWrite(ENB,0); delay(1000); } ``` **6.Result** After connection and power-on, two motors rotate clockwise for 1 second at a speed of 200 (PWM value is 200) and then stop for 1 second; two motors rotate anticlockwise for 1 second at a speed of 100 (PWM value is 100) and then stop for 1 second.